package com.zone.types.common;

public class Constants {

    public final static String SPLIT = ",";

    public static class RedisKey {
        /** 策略明细缓存key */
        public static String STRATEGY_AWARD_KEY = "big_market_strategy_award_key:%s";
        /** 奖品-范围表 */
        public static String AWARD_RANGE_TABLE_KEY = "award_range_table_key:%s";
        /** 奖品-范围 */
        public static String AWARD_RATE_RANGE_KEY = "award_rate_range_key:%s";
        /** 奖品库存  award_stock_key:strategyId:awardId */
        public static String AWARD_STOCK_KEY = "award_stock_key:%s:%s";
        /** 奖品库存数量  award_stock_count_key:strategyId:awardId:stockCount */
        public static String AWARD_STOCK_COUNT_KEY = "award_stock_count_key:%s:%s:%s";
        /** 奖品库存扣减延迟队列 */
        public static String AWARD_STOCK_QUEUE_KEY = "award_stock_queue_key";
        /** 活动库存 activity_stock_key:sku */
        public static String ACTIVITY_STOCK_KEY = "activity_stock_key:%s";
        /** 活动库存数量 activity_stock_count_key:sku:stockCount */
        public static String ACTIVITY_STOCK_COUNT_KEY = "activity_stock_count_key:%s:%s";
        /** 活动sku库存扣减延迟队列 activity_sku_stock_desc_queue:sku */
        public static String ACTIVITY_SKU_STOCK_DESC_QUEUE = "activity_sku_stock_desc_queue:%s";
        /** 用户积分账户锁 user_credit_account_lock:userId */
        public static String USER_CREDIT_ACCOUNT_LOCK = "user_credit_account_lock:%s";
        /** 用户活动账户锁 activity_account_lock:userId:activityId */
        public static String ACTIVITY_ACCOUNT_LOCK = "activity_account_lock:%s:%s";

        /**
         * 生成redis key
         *
         * @param key    redis key
         * @param values 生成key需要的值
         * @return 生成完毕的redis key
         */
        public static String generate(String key, Object... values) {
            if (values == null || values.length == 0) {
                return key;
            }
            return String.format(key, values);
        }
    }
}
